﻿Imports tiendaRegalos
Public Class SesionNegocio

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim negocio As New UsuarioNegocio

        Try
            Dim modelo = negocio.login(Me.txtnombre.Text, Me.txtpassword.Text)

            Dim mdi As MDIParent1 = New MDIParent1
            mdi.IngresarToolStripMenuItem.Visible = False
            mdi.IngresarToolStripMenuItem.Visible = False

            Dim listaRoles = modelo.usuarios

            For Each x As Rol In listaRoles

                ' Si es Administrador
                If Constantes.ROL_ADMIN = x.idRol Then
                    mdi.IngresarToolStripMenuItem.Visible = True
                End If

                ' Si es Vendedor
                If Constantes.ROL_VENTAS = x.idRol Then
                    mdi.IngresarPorCategoríaToolStripMenuItem.Visible = True
                End If

            Next

            mdi.Show()
            Me.Visible = False

        Catch ex As Exception
            MsgBox(ex.ToString)
            Me.lblError.Text = "Usuario y/o Clave incorrectos" + ex.ToString
        End Try
    End Sub
End Class